package com.lgmshare.k3.ui.setting;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.Button;
import android.widget.TextView;

import com.lgmshare.component.utils.ContextUtils;
import com.lgmshare.component.utils.UIUtils;
import com.lgmshare.k3.K3Application;
import com.lgmshare.k3.K3Config;
import com.lgmshare.k3.R;
import com.lgmshare.k3.manager.UserSettingManager;
import com.lgmshare.k3.ui.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

public class RuntimeActivity extends BaseActivity {
    @BindView(R.id.tv_phoneInfo)
    TextView tvPhoneInfo;
    @BindView(R.id.tv_modeInfo)
    TextView tvModeInfo;
    @BindView(R.id.btn_switch)
    Button btnSwitch;

    @Override
    protected int onBindLayoutResId() {
        return R.layout.activity_runtime;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        super.initView();
        setToolbarTitle("运行模式");

        String phoneInfo = ContextUtils.getPhoneInfo(UIUtils.getContext());
        tvPhoneInfo.setText(phoneInfo);
        String[] modes = getResources().getStringArray(R.array.runtime_mode);
        String info = "RuntimeMode：" + modes[UserSettingManager.getInstance().getRuntimeMode()] +
                "\nDebug：" + K3Config.DEBUG_MODE +
                "\nHttpUrl：" + K3Config.URL_HTTP_INTERFACE;
        tvModeInfo.setText(info);
    }

    @Override
    protected void initLoad() {

    }

    @OnClick(R.id.btn_switch)
    public void clickSwitchMode() {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setCancelable(false);
        builder.setItems(R.array.runtime_mode, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                UserSettingManager.getInstance().setRuntimeMode(which);
                K3Application.getInstance().exit();
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }
}
